using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class UDF_PageMap : EntityTypeConfiguration<UDF_Page>
    {
        public UDF_PageMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.ID)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.Name)
                .IsRequired()
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("UDF_Page");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.FormOptionsID).HasColumnName("FormOptionsID");
            this.Property(t => t.Name).HasColumnName("Name");
            this.Property(t => t.Order).HasColumnName("Order");
            this.Property(t => t.Columns).HasColumnName("Columns");
            this.Property(t => t.Rowheight).HasColumnName("Rowheight");
            this.Property(t => t.ShowBorders).HasColumnName("ShowBorders");
            this.Property(t => t.RightBorder).HasColumnName("RightBorder");
            this.Property(t => t.LeftBorder).HasColumnName("LeftBorder");
            this.Property(t => t.TopBorder).HasColumnName("TopBorder");
            this.Property(t => t.BootomBorder).HasColumnName("BootomBorder");
            this.Property(t => t.BottomBorder).HasColumnName("BottomBorder");

            // Relationships
            this.HasRequired(t => t.UDF_FormOptions)
                .WithMany(t => t.UDF_Page)
                .HasForeignKey(d => d.FormOptionsID);

        }
    }
}
